package com.m.demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKInvocation implements InvocationHandler {
    private Object target;
    public JDKInvocation(Object target) {
        this.target = target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始代理...");
        //调用目标对象，proxy是目标对象
        Object result = method.invoke(target, args);
        System.out.println("结束代理...");
        return result;
    }
}
